package com.lanou.utp.controller;

import com.lanou.utp.entity.Paging;
import com.lanou.utp.entity.ResponseData;
import com.lanou.utp.entity.Warning;
import com.lanou.utp.service.WarningService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class WarningController {

    @Resource
    private WarningService warningService;

    @GetMapping("/warnings")
    public ResponseData getWarnings(@RequestParam(value = "page", defaultValue = "1") Integer page, @RequestParam(value = "size", defaultValue = "10") Integer size) {
        List<Warning> warnings = warningService.getWarnings(page, size);
        Paging paging = warningService.getPaging(page, size);
        return new ResponseData(warnings, paging);
    }

}
